package com.xuecheng.content.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuecheng.content.model.dto.TeachPlanDto;
import com.xuecheng.content.model.po.Teachplan;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 课程计划 Mapper 接口
 * </p>
 *
 * @author itcast
 */
@Mapper
public interface TeachplanMapper extends BaseMapper<Teachplan> {

    /**
     * 根据课程id查询课程计划
     * @param courseId
     * @return
     */
    public List<TeachPlanDto> selectTreeNodeList(Long courseId);

    /**
     * 获取课程计划最大顺序号
     * @param queryWrapper
     * @return
     */
    @Select("select max(orderby) from teachplan ${ew.customSqlSegment}")
    Integer selectMax(@Param("ew") LambdaQueryWrapper<Teachplan> queryWrapper);



    /**
     * 根据条件查询课程计划
     * @param queryWrapper
     * @return
     */
    @Select("select * from teachplan where course_id = #{courseId} and parentid = #{parentid} and grade = #{grade}" )
    List<Teachplan> list(@Param("courseId") Long courseId, @Param("parentid")Long parentid, @Param("grade")Integer grade);
}
